using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using Utility;
public partial class admin_A_phieudeal_update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Loaddata();
            LoadDropDownList();
        }
    }
    private void Loaddata()
    {
        string id = Request.QueryString["MAPHIEU"].ToString();
        l_maphieu.Text = id;
        Phieu_Deal_DTO phieuDeal = Phieu_Deal_BUS.GetByID(id);

        l_mathang.Text = phieuDeal.MaCTHD.ToString();
        ddl_TinhTrangPhieu.Text = phieuDeal.MaTinhTrang_Phieu.ToString();
    }

    private void LoadDropDownList()
    {

        TinhTrang_PhieuCollection tinhTrangPhieuCollection = TinhTrang_Phieu_BUS.GetAll();
        ddl_TinhTrangPhieu.DataTextField = TinhTrang_PhieuColumns.TenTinhTrang.ToString();
        ddl_TinhTrangPhieu.DataValueField = TinhTrang_PhieuColumns.MaTinhTrang_Phieu.ToString();
        ddl_TinhTrangPhieu.DataSource = tinhTrangPhieuCollection;
        ddl_TinhTrangPhieu.DataBind();
        //ddl_TinhTrangPhieu.Items.Insert(0, new ListItem("All", ""));

    }
    protected void btcapnhat_Click(object sender, EventArgs e)
    {
        string id = Request.QueryString["MAPHIEU"].ToString();
        Phieu_Deal_DTO phieuDeal = Phieu_Deal_BUS.GetByID(id);
        phieuDeal.ID = l_maphieu.Text;
        phieuDeal.MaCTHD = int.Parse(l_mathang.Text);
        phieuDeal.MaTinhTrang_Phieu = int.Parse(ddl_TinhTrangPhieu.SelectedValue);
        Phieu_Deal_BUS.Update(phieuDeal);

        Response.Redirect(Request.RawUrl);
    }
}
